Controlling Sounds with JavaScript : Audio Video Sound « Development « JavaScript DHTML






Controlling Sounds with JavaScript


<html>
<head>
  <title>JavaScript Unleashed</title>
  <script type="text/javascript">
  <!--
    function playSound(sfile) {
   
      // load a sound and play it
      window.location.href=sfile;
    }
  //-->
  </script>
</head>
<body onLoad="playSound('yourFile.wav')" onUnLoad="playSound('Glass.wav')">
  <a href="#" onClick="playSound('Cashreg.wav')">
    Click here for sound
  </a>

  <p>
    <form name="form1">
      <input type="button" value="Play" onClick="playSound('Gunshot.wav')">
    </form>
  </p>
</body>
</html>

           
       








Related examples in the same category

1.Inserts an audio or video medium in the current Web page
2. Accessing a Plug-In
3.Controlling Embedded Sounds with JavaScript